/*
 * Copyright (c) 2009-2024 Arm Limited. All rights reserved.
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the License); you may
 * not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*============================ INCLUDES ======================================*/

#define __USER_SCENE0_IMPLEMENT__
#include "arm_2d_scene_0.h"
#include "ff.h"

#if defined(RTE_Acceleration_Arm_2D_Helper_PFB)

#ifdef RTE_Acceleration_Arm_2D_Scene0

#include <stdlib.h>
#include <string.h>
#include "GUI_button.h" 
#include "GUI_label.h" 
#include "GUI_core.h" 
#include "./progress_bar_flowing.h"
#include "./progress_bar_drill.h"

#if defined(__clang__)
#   pragma clang diagnostic push
#   pragma clang diagnostic ignored "-Wunknown-warning-option"
#   pragma clang diagnostic ignored "-Wreserved-identifier"
#   pragma clang diagnostic ignored "-Wsign-conversion"
#   pragma clang diagnostic ignored "-Wpadded"
#   pragma clang diagnostic ignored "-Wcast-qual"
#   pragma clang diagnostic ignored "-Wcast-align"
#   pragma clang diagnostic ignored "-Wmissing-field-initializers"
#   pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
#   pragma clang diagnostic ignored "-Wmissing-prototypes"
#   pragma clang diagnostic ignored "-Wunused-variable"
#   pragma clang diagnostic ignored "-Wgnu-statement-expression"
#   pragma clang diagnostic ignored "-Wdeclaration-after-statement"
#   pragma clang diagnostic ignored "-Wunused-function"
#   pragma clang diagnostic ignored "-Wmissing-declarations"
#   pragma clang diagnostic ignored "-Wimplicit-int-conversion" 
#elif __IS_COMPILER_ARM_COMPILER_5__
#   pragma diag_suppress 64,177
#elif __IS_COMPILER_IAR__
#   pragma diag_suppress=Pa089,Pe188,Pe177,Pe174
#elif __IS_COMPILER_GCC__
#   pragma GCC diagnostic push
#   pragma GCC diagnostic ignored "-Wformat="
#   pragma GCC diagnostic ignored "-Wpedantic"
#   pragma GCC diagnostic ignored "-Wunused-function"
#   pragma GCC diagnostic ignored "-Wunused-variable"
#   pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
#endif

/*============================ MACROS ========================================*/

#if __GLCD_CFG_COLOUR_DEPTH__ == 8

#   define c_tileCMSISLogo          c_tileCMSISLogoGRAY8

#elif __GLCD_CFG_COLOUR_DEPTH__ == 16

#   define c_tileCMSISLogo          c_tileCMSISLogoRGB565

#elif __GLCD_CFG_COLOUR_DEPTH__ == 32

#   define c_tileCMSISLogo          c_tileCMSISLogoCCCA8888
#else
#   error Unsupported colour depth!
#endif

/*============================ MACROFIED FUNCTIONS ===========================*/
#undef this
#define this (*ptThis)

/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/

extern const arm_2d_tile_t c_tileCMSISLogo;
extern const arm_2d_tile_t c_tileCMSISLogoMask;
extern const arm_2d_tile_t c_tileCMSISLogoA2Mask;
extern const arm_2d_tile_t c_tileCMSISLogoA4Mask;
/*============================ PROTOTYPES ====================================*/
/*============================ LOCAL VARIABLES ===============================*/

/*! define dirty regions */
IMPL_ARM_2D_REGION_LIST(s_tDirtyRegions, static)

    /* a dirty region to be specified at runtime*/
    ADD_REGION_TO_LIST(s_tDirtyRegions,
        0  /* initialize at runtime later */
    ),
    ADD_REGION_TO_LIST(s_tDirtyRegions,        0 ),  /* initialize at runtime later */ 
    ADD_REGION_TO_LIST(s_tDirtyRegions,        0 ),
    ADD_REGION_TO_LIST(s_tDirtyRegions,        0 ),
    ADD_REGION_TO_LIST(s_tDirtyRegions,        0 ),
    ADD_REGION_TO_LIST(s_tDirtyRegions,        0 ),
    ADD_REGION_TO_LIST(s_tDirtyRegions,        0 ),
    ADD_REGION_TO_LIST(s_tDirtyRegions,        0 ),
    ADD_REGION_TO_LIST(s_tDirtyRegions,        0 ),
    ADD_REGION_TO_LIST(s_tDirtyRegions,        0 ),
    /* add the last region:
        * it is the top left corner for text display 
        */
    ADD_LAST_REGION_TO_LIST(s_tDirtyRegions,
        .tLocation = {
            .iX = 0,
            .iY = 0,
        },
        .tSize = {
            .iWidth = 0,
            .iHeight = 8,
        },
    ),

END_IMPL_ARM_2D_REGION_LIST(s_tDirtyRegions)

/*============================ IMPLEMENTATION ================================*/

static void __on_scene0_load(arm_2d_scene_t *ptScene)
{
    user_scene_0_t *ptThis = (user_scene_0_t *)ptScene;
    ARM_2D_UNUSED(ptThis);
    //this.use_as__arm_2d_scene_t.bUseDirtyRegionHelper
    //arm_2d_helper_pfb_disable_dirty_region_optimization(&ptScene->ptPlayer->use_as__arm_2d_helper_pfb_t);
    

}

static void __after_scene0_switching(arm_2d_scene_t *ptScene)
{
    user_scene_0_t *ptThis = (user_scene_0_t *)ptScene;
    ARM_2D_UNUSED(ptThis);

}

static void __on_scene0_depose(arm_2d_scene_t *ptScene)
{
    user_scene_0_t *ptThis = (user_scene_0_t *)ptScene;
    ARM_2D_UNUSED(ptThis);
    
    ptScene->ptPlayer = NULL;
    
    /* reset timestamp */
    arm_foreach(int64_t,this.lTimestamp, ptItem) {
        *ptItem = 0;
    }

    if (!this.bUserAllocated) {
        __arm_2d_free_scratch_memory(ARM_2D_MEM_TYPE_UNSPECIFIED, ptScene);
    }
}

/*----------------------------------------------------------------------------*
 * Scene 0                                                                    *
 *----------------------------------------------------------------------------*/

static void __on_scene0_background_start(arm_2d_scene_t *ptScene)
{
    user_scene_0_t *ptThis = (user_scene_0_t *)ptScene;
    ARM_2D_UNUSED(ptThis);

}

static void __on_scene0_background_complete(arm_2d_scene_t *ptScene)
{
    user_scene_0_t *ptThis = (user_scene_0_t *)ptScene;
    ARM_2D_UNUSED(ptThis);

}

void boll_move();
static void __on_scene0_frame_start(arm_2d_scene_t *ptScene)
{
    user_scene_0_t *ptThis = (user_scene_0_t *)ptScene;
    ARM_2D_UNUSED(ptThis);

}

static void __on_scene0_frame_complete(arm_2d_scene_t *ptScene)
{
    user_scene_0_t *ptThis = (user_scene_0_t *)ptScene;
    ARM_2D_UNUSED(ptThis);
    //boll_move();

#if 1
    /* switch to next scene after 3s */
    if (arm_2d_helper_is_time_out(200, &this.lTimestamp[0])) {
        //arm_2d_scene_player_switch_to_next_scene(ptScene->ptPlayer);
        //boll_move();
    }
#endif
}

static void __before_scene0_switching_out(arm_2d_scene_t *ptScene)
{
    user_scene_0_t *ptThis = (user_scene_0_t *)ptScene;
    ARM_2D_UNUSED(ptThis);

}

static char wordbuffer[20];
static button_control_t s_tButton;
my_label_t g_labels;

gui_control_t control_button1;
gui_control_t control_label1;

extern const arm_2d_tile_t *Font16_tp[13];
extern const arm_2d_tile_t *Font24_tp[13];

//arm_2d_tile_t **Font_tp = Font16_tp;
void draw_string_for_pic(const arm_2d_tile_t *ptTile,  arm_2d_region_t tRegion,const arm_2d_tile_t *Font[],char *str,uint8_t op);

void draw_ballvoid (void *pTarget,                                   
                                const arm_2d_tile_t *ptTile,                     
                                bool bIsNewFrame);

static
IMPL_PFB_ON_DRAW(__pfb_draw_scene0_handler)
{
    user_scene_0_t *ptThis = (user_scene_0_t *)pTarget;
    arm_2d_size_t tScreenSize = ptTile->tRegion.tSize;
    
    ARM_2D_UNUSED(ptTile);
    ARM_2D_UNUSED(bIsNewFrame);
    ARM_2D_UNUSED(tScreenSize);
    
    arm_2d_canvas(ptTile, __top_canvas) {
    /*-----------------------draw the foreground begin-----------------------*/
        
        /* following code is just a demo, you can remove them */
        arm_2d_align_centre(__top_canvas, 30, 20 ) {
            
            // 绘制按钮  
//            button_draw(control_button1.control, ptTile, bIsNewFrame);  
//            
//            my_label_draw(control_label1.control, ptTile,bIsNewFrame)  ;
            
             //GUI_draw( ptTile,bIsNewFrame)  ;
            
            draw_round_corner_box(  ptTile, 
                                    &__centre_region, 
                                    GLCD_COLOR_BLACK, 
                                    105,
                                    bIsNewFrame);
//            
//            ARM_2D_OP_WAIT_ASYNC();
//            
//            draw_round_corner_border(   ptTile, 
//                                        &__centre_region, 
//                                        GLCD_COLOR_BLACK, 
//                                        (arm_2d_border_opacity_t)
//                                            {32, 32, 255-64, 255-64},
//                                        (arm_2d_corner_opacity_t)
//                                            {0, 128, 128, 128});
//                                    
        }
        
        do{
            static uint16_t iProgress = 0;
            if(bIsNewFrame){
                iProgress+=20;
                if(iProgress > 1000){
                    iProgress = 0;
                }
            }
             arm_2d_align_centre(__top_canvas, 100, 20) {  
                // 调用流动进度条绘制函数  
                // progress_bar_flowing_show(...);  
//                 s_tDirtyRegions[6].tRegion =  __centre_region;
//                 __progress_bar_drill_show( ptTile,
//                                &__centre_region,
//                                         iProgress,
//                                GLCD_COLOR_GREEN,
//                                  bIsNewFrame);
//                 __progress_bar_flowing_show(    ptTile,
//                                        &__centre_region,
//                                          iProgress,
//                                          bIsNewFrame, 
//                                        GLCD_COLOR_WHITE,
//                                        GLCD_COLOR_GREEN,
//                                        GLCD_COLOR_BLUE);
            } 
            arm_2d_align_top_centre(__top_canvas, 24*4, 60) {
                arm_2d_align_centre(__top_centre_region, 24*4, 24) { 
                    draw_string_for_pic( ptTile,  __centre_region,Font24_tp,"0123",240);
                }
            }
           
        }while(0);         

        draw_ballvoid ( pTarget, ptTile,bIsNewFrame);

        /* draw text at the top-left corner */

        arm_lcd_text_set_target_framebuffer((arm_2d_tile_t *)ptTile);
        arm_lcd_text_set_font(&ARM_2D_FONT_6x8.use_as__arm_2d_font_t);
        arm_lcd_text_set_draw_region(NULL);
        arm_lcd_text_set_colour(GLCD_COLOR_RED, GLCD_COLOR_WHITE);
        arm_lcd_text_location(0,0);
        //arm_lcd_puts("Scene 0");
        
        arm_lcd_text_location(1,0);
        arm_lcd_puts(wordbuffer);
        
        

    /*-----------------------draw the foreground end  -----------------------*/
    }
    ARM_2D_OP_WAIT_ASYNC();

    return arm_fsm_rt_cpl;
}

void boll_init();

ARM_NONNULL(1)
user_scene_0_t *__arm_2d_scene0_init(   arm_2d_scene_player_t *ptDispAdapter, 
                                        user_scene_0_t *ptThis)
{
    bool bUserAllocated = false;
    assert(NULL != ptDispAdapter);

    s_tDirtyRegions[dimof(s_tDirtyRegions)-1].ptNext = NULL;

    /* get the screen region */
    arm_2d_region_t tScreen
        = arm_2d_helper_pfb_get_display_area(
            &ptDispAdapter->use_as__arm_2d_helper_pfb_t);

    /* initialise dirty region 0 at runtime
     * this demo shows that we create a region in the centre of a screen(320*240)
     * for a image stored in the tile c_tileCMSISLogoMask
     */
//    arm_2d_align_centre(tScreen, c_tileCMSISLogoMask.tRegion.tSize) {
//        s_tDirtyRegions[0].tRegion = __centre_region;
//    }

    s_tDirtyRegions[dimof(s_tDirtyRegions)-1].tRegion.tSize.iWidth 
                                                        = tScreen.tSize.iWidth;
    
    if (NULL == ptThis) {
        ptThis = (user_scene_0_t *)
                    __arm_2d_allocate_scratch_memory(   sizeof(user_scene_0_t),
                                                        __alignof__(user_scene_0_t),
                                                        ARM_2D_MEM_TYPE_UNSPECIFIED);
        assert(NULL != ptThis);
        if (NULL == ptThis) {
            return NULL;
        }
    } else {
        bUserAllocated = true;
    }
    memset(ptThis, 0, sizeof(user_scene_0_t));

    *ptThis = (user_scene_0_t){
        .use_as__arm_2d_scene_t = {

            /* the canvas colour */
            .tCanvas = {GLCD_COLOR_BLACK}, 

            /* Please uncommon the callbacks if you need them
             */
            .fnOnLoad       = &__on_scene0_load,
            .fnScene        = &__pfb_draw_scene0_handler,
            //.fnAfterSwitch  = &__after_scene0_switching,

            /* if you want to use predefined dirty region list, please uncomment the following code */
            .ptDirtyRegion  = (arm_2d_region_list_item_t *)s_tDirtyRegions,
            

            //.fnOnBGStart    = &__on_scene0_background_start,
            //.fnOnBGComplete = &__on_scene0_background_complete,
            .fnOnFrameStart = &__on_scene0_frame_start,
            //.fnBeforeSwitchOut = &__before_scene0_switching_out,
            .fnOnFrameCPL   = &__on_scene0_frame_complete,
            .fnDepose       = &__on_scene0_depose,

            .bUseDirtyRegionHelper = false,
        },
        .bUserAllocated = bUserAllocated,
    };

    /* ------------   initialize members of user_scene_0_t begin ---------------*/
        FIL file; // 文件对象
    FRESULT res; // 函数返回值
    
    res = f_open(&file, "/TXT/word.txt",  FA_READ); // 创建文件
    if (res == FR_OK) {
        
        UINT bytes_read;
        res = f_read(&file, wordbuffer, sizeof(wordbuffer), &bytes_read); // 读取数据
        wordbuffer[10] = 0;
        //lcd_print(  0, 60, buffer);
        //lcd_print(  0, 140, buffer);
        res = f_close(&file); // 关闭文件
    }
    
    
    arm_2d_region_t tButtonRegion = {  
            .tLocation = {10, 100},  
            .tSize = {80, 40}  
        };  
       button_init(&s_tButton,   
                   &tButtonRegion,   
                   "OK",   
                   (__arm_2d_color_t){GLCD_COLOR_BLUE},   
                   (__arm_2d_color_t){GLCD_COLOR_NAVY},   
                   (__arm_2d_color_t){GLCD_COLOR_DARK_GREY},//GLCD_COLOR_GRAY,   
                   (__arm_2d_color_t){GLCD_COLOR_WHITE});
       button_add_gui_control(&s_tButton,&control_button1);            
                   
       arm_2d_region_t region1 = {.tLocation = {10, 10}, .tSize = {80, 30}};  
       my_label_init(&g_labels, region1, "are you OK?", ARM_2D_ALIGN_TOP_RIGHT,   
                 GLCD_COLOR_BLACK, GLCD_COLOR_WHITE, &ARM_2D_FONT_6x8.use_as__arm_2d_font_t);  
                  
       label_add_gui_control(&g_labels,&control_label1);    
    /* ------------   initialize members of user_scene_0_t end   ---------------*/
    boll_init();
       progress_bar_flowing_init( );
       progress_bar_drill_init( );
    arm_2d_scene_player_append_scenes(  ptDispAdapter, 
                                        &this.use_as__arm_2d_scene_t, 
                                        1);

    return ptThis;
}

//=========================================
extern const arm_2d_tile_t c_tileyuanMask;
extern const arm_2d_tile_t c_tileyuanGRAY8;

                                
#include <stdlib.h>  
#include <time.h>  
  
// 初始化随机数种子  
//srand((unsigned int)time(NULL));  
  
// 生成随机数  

uint16_t boll_color[6] = {
    GLCD_COLOR_DARK_GREEN,
    
    GLCD_COLOR_ORANGE,
    GLCD_COLOR_MAROON,
    GLCD_COLOR_RED,
    GLCD_COLOR_BLUE,
    GLCD_COLOR_YELLOW,
};

                                
typedef struct boll_{
    
    arm_2d_region_t tRegion;
    arm_2d_color_rgb565_t tColour;
    uint8_t chOpacity;
    uint8_t speed_x;
    uint8_t speed_y;
    uint8_t speed_flag_x;//0+    1-
    uint8_t speed_flag_y;//0+    1-
    
}boll_t;
#define BOLL_NUM  5
#define MOVE_X_SPEED (1+ (rand() % 4))
#define MOVE_Y_SPEED (1+ (rand() % 4))

boll_t my_bools[BOLL_NUM];

void boll_init(){
    int i;
    int random_number = rand();
    for(i = 0; i < BOLL_NUM; i++){
        my_bools[i].speed_x = MOVE_X_SPEED;//10  +(rand() % 10);
        my_bools[i].speed_y = MOVE_Y_SPEED;//5   +(rand() % 5);
        my_bools[i].speed_flag_x = 0;
        my_bools[i].speed_flag_y = 0;
        my_bools[i].chOpacity = 100 + rand() % (100  );
        my_bools[i].tColour.tValue = boll_color[i%6];
        my_bools[i].tRegion.tSize.iHeight = 50;
        my_bools[i].tRegion.tSize.iWidth  = 50;
        my_bools[i].tRegion.tLocation.iX =  10 + 50 *i;//10 +(rand() % 240);
        my_bools[i].tRegion.tLocation.iY = 10 +(rand() % 100);
    }
}

#define MOVE_X  270
#define MOVE_Y  120

char check_boll(char num){
    int i,x,y,dist ;
    
    for(i = 0; i < BOLL_NUM; i++){
        if(i == num){
            continue;
        }
        x = (my_bools[i].tRegion.tLocation.iX - my_bools[num].tRegion.tLocation.iX) ;
        y = (my_bools[i].tRegion.tLocation.iY - my_bools[num].tRegion.tLocation.iY) ;
        dist = x*x + y*y;
        if(dist <= 2500){
            return 1;
        }
    }
    return 0;
}

void boll_move(){
    int i;
    for(i = 0; i < BOLL_NUM; i++){
        s_tDirtyRegions[i*2].tRegion =  my_bools[i].tRegion;
        if(my_bools[i].speed_flag_x == 0){
            my_bools[i].tRegion.tLocation.iX += my_bools[i].speed_x;
            if(my_bools[i].tRegion.tLocation.iX > MOVE_X){
                my_bools[i].tRegion.tLocation.iX = MOVE_X;
                my_bools[i].speed_flag_x = 1;
                my_bools[i].speed_x = MOVE_X_SPEED;//10  +(rand() % 10);   
            }
        }else{
            my_bools[i].tRegion.tLocation.iX -= my_bools[i].speed_x;
            if(my_bools[i].tRegion.tLocation.iX < 0){
                my_bools[i].tRegion.tLocation.iX = 0;
                my_bools[i].speed_flag_x = 1;
                my_bools[i].speed_x = MOVE_X_SPEED;//10  +(rand() % 10);   
            }
        }
        if(my_bools[i].speed_flag_y == 0){
            my_bools[i].tRegion.tLocation.iY += my_bools[i].speed_y;
            if(my_bools[i].tRegion.tLocation.iY > MOVE_Y){
                my_bools[i].tRegion.tLocation.iY = MOVE_Y;
                my_bools[i].speed_flag_y = 1;
                my_bools[i].speed_y = MOVE_Y_SPEED;//5   +(rand() % 5);
            }
            
        }else{
            my_bools[i].tRegion.tLocation.iY -= my_bools[i].speed_y;
            if(my_bools[i].tRegion.tLocation.iY < 0){
                my_bools[i].tRegion.tLocation.iY = 0;
                my_bools[i].speed_flag_y = 0;
                my_bools[i].speed_y = MOVE_Y_SPEED;//5   +(rand() % 5);
            }
        }
        if(check_boll(i)){
            if(my_bools[i].speed_flag_x == 0){
                my_bools[i].tRegion.tLocation.iX -= 5;
                my_bools[i].speed_flag_x = 1;
            }else{
                my_bools[i].tRegion.tLocation.iX += 5;
                my_bools[i].speed_flag_x = 0;
            }
            
            if(my_bools[i].speed_flag_y == 0){
                my_bools[i].tRegion.tLocation.iY -= 5;
                my_bools[i].speed_flag_y = 1;
            }else{
                my_bools[i].tRegion.tLocation.iY += 5;
                my_bools[i].speed_flag_y = 0;
            }
                       
            //my_bools[i].speed_flag  = 0;
            my_bools[i].speed_x = MOVE_X_SPEED;// 10  +(rand() % 10); 
            my_bools[i].speed_y = MOVE_Y_SPEED;//5   +(rand() % 5);
        }
        s_tDirtyRegions[i*2+1].tRegion =  my_bools[i].tRegion;
    }
}
static uint16_t num = 0;
void boll_move_Rotation(){
    static char time = 0;
    time++;
    if(time >= 12){
        time = 0;
        num++;
    }
}

extern const arm_2d_tile_t c_tileyuan5RGB565;
extern const arm_2d_tile_t c_tileyuan5GRAY8;
void draw_ballvoid (void *pTarget,                                   
                                const arm_2d_tile_t *ptTile,                     
                                bool bIsNewFrame){
                                    
    
    
    int i;
   
    if(bIsNewFrame){
        boll_move();
        //boll_move_Rotation();
        
    }
#if 0     
    for( i = 0 ; i < BOLL_NUM; i++ ){ 
        arm_2dp_rgb565_fill_colour_with_mask_and_opacity(
                                        NULL,               // 使用默认操作控制块  
                                        ptTile,       // 目标tile  
                                        &my_bools[i].tRegion,               // 使用整个目标区域  
                                        &c_tileyuan5GRAY8,//c_tileyuanGRAY8,    // mask tile  
                                        my_bools[i].tColour ,        // 蓝色
                                        my_bools[i].chOpacity);    
        arm_2dp_rgb565_tile_copy_with_src_mask_and_opacity_only(  
                            NULL,                  // 操作描述符  
                            &c_tileyuan5RGB565,         // 源RGB565图像tile  
                            &c_tileyuan5GRAY8,           // 掩码图像tile(灰度图，黑色表示完全透明)  
                            ptTile,         // 目标图像tile  
                            &my_bools[i].tRegion,              // 感兴趣区域  
                            200//my_bools[i].chOpacity               // 全局透明度值(0-255)  
                        );
    }
#endif
    
#if 0    
    for( i = 0 ; i < BOLL_NUM; i++ ){
        arm_2dp_rgb565_tile_copy_with_colour_keying_and_opacity(  
                            NULL,                  // 操作描述符  
                            &c_tileyuan5RGB565,         // 源图像tile  
                            ptTile,         // 目标图像tile  
                            &my_bools[i].tRegion,              // 感兴趣区域  
                            255,//my_bools[i].chOpacity,              // 透明度值(0-255)  
                            (arm_2d_color_rgb565_t){0} // 黑色作为透明色  
                        );
    }
#endif
    
#if 1    
    for( i = 0 ; i < BOLL_NUM; i++ ){
        if((num%4)== 0)
        arm_2dp_rgb565_fill_colour_with_mask_and_opacity(
                                        NULL,               // 使用默认操作控制块  
                                        ptTile,       // 目标tile  
                                        &my_bools[i].tRegion,               // 使用整个目标区域  
                                        &c_tileyuan5GRAY8,//c_tileyuanGRAY8,    // mask tile  
                                        my_bools[i].tColour ,        // 蓝色
                                        my_bools[i].chOpacity);
        if((num%4)== 1)
        arm_2d_rgb565_fill_colour_with_mask_x_mirror_and_opacity(  
                                        ptTile,      // 目标图块地址  
                                        &my_bools[i].tRegion,           // 目标区域地址  
                                        &c_tileyuan5GRAY8,       // alpha 蒙版地址  
                                        my_bools[i].tColour,               // 颜色  
                                        my_bools[i].chOpacity               // 不透明度  
                                    );
        if((num%4)== 2)
        arm_2d_rgb565_fill_colour_with_mask_xy_mirror_and_opacity(  
                                        ptTile,      // 目标图块地址  
                                        &my_bools[i].tRegion,           // 目标区域地址  
                                        &c_tileyuan5GRAY8,       // alpha 蒙版地址  
                                        my_bools[i].tColour,               // 颜色  
                                        my_bools[i].chOpacity               // 不透明度  
                                    );
        if((num%4)== 3)
        arm_2d_rgb565_fill_colour_with_mask_y_mirror_and_opacity(  
                                        ptTile,      // 目标图块地址  
                                        &my_bools[i].tRegion,           // 目标区域地址  
                                        &c_tileyuan5GRAY8,       // alpha 蒙版地址  
                                        my_bools[i].tColour,               // 颜色  
                                        my_bools[i].chOpacity               // 不透明度  
                                    );                            
    }
#endif
    

}


#if defined(__clang__)
#   pragma clang diagnostic pop
#endif

#endif

#endif

